<template>
    <div>
        <el-table :data="topicList" stripe style="width: 100%">
            <el-table-column prop="id" label="ID" width="80" />
            <el-table-column label="分类">
                <template slot-scope="scope">
                    <div>{{ typeName(scope.row.type_id) }}</div>
                </template>
            </el-table-column>
            <el-table-column prop="title" label="标题" width="180" />
            <el-table-column prop="conents" label="课题要求" width="520" />
            <el-table-column prop="teacher.name" label="指导老师" width="120" />
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button size="mini" type="success" @click="examine({topic_id:scope.row.id,state: 2,page,pagesize})">通过</el-button>
                    <el-button size="mini" type="danger" @click="examine({topic_id:scope.row.id,state: 1,page,pagesize})">驳回</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="page">
            <el-pagination background layout="prev, pager, next" :total="total" :page-size="pagesize" @current-change="cheangePage"/>
        </div>
    </div>
</template>

<script>
    import { mapState,mapActions } from 'vuex';
    export default {
        name: 'WebTopicProcess',
        data() {
            return {
                page: 0,
                pagesize: 13
            };
        },
        computed: {
            ...mapState('Topic',['topicList','total','typeList']),
            typeName(){
                return (type_id) => {
                    let type = this.typeList.filter((n) => {
                        return n.id == type_id;
                    })
                    return type[0].name;
                }
            }
        },
        methods: {
            ...mapActions('Topic',['getInspect','examine','getTypes']),
            cheangePage(page){
                let { pagesize } = this;
                this.page = --page;
                this.getInspect({page,pagesize});
            }
        },
        mounted(){
            let { page,pagesize } = this;
            this.getInspect({page,pagesize});
            this.getTypes();
        }
    };
</script>

<style lang="less" scoped>
    @import "asle/index.less";
    .page {
        .pos_f();
        .pos_rb(20px,20px);
    }
</style>